<?php

/**
 *      [Discuz!] (C)2001-2099 Comsenz Inc.
 *      This is NOT a freeware, use is subject to license terms
 *
 *      $Id: space_notice.php 34047 2013-09-25 04:41:45Z nemohou $
 */

if(!defined('IN_DISCUZ')) {
	exit('Access Denied');
}

/* $res = DB::fetch_all('select * from %t,array('pre_common_member'));*/
/* echo "<pre>";
print_r($res);
 echo "</pre>";*/

$perpage = 20;
$perpage = mob_perpage($perpage);

$page = empty($_GET['page'])?1:intval($_GET['page']);
if($page<1) $page=1;
$start = ($page-1)*$perpage;

ckstart($start, $perpage);

$theurl = "home.php?mod=space&uid=$space[uid]&do=$do";

$diymode = 1;

$list = array();
$list = DB::fetch_all('select a.*,b.subject,b.author from pre_yy_pay_log as a left join pre_forum_thread as b on b.tid=a.pl_pid where a.pl_cid=0 and a.pl_uid='.$space['uid'].'');
foreach ($list as $key => $value) {
	$list[$key]['pl_time'] = get_last_time(strtotime($value['pl_time']));
}
/**
 * 获取已经过了多久
 * PHP时间转换
 * 刚刚、几分钟前、几小时前
 * 今天昨天前天几天前
 * @param  string $targetTime 时间戳
 * @return string
 */
function get_last_time($targetTime)
{
    // 今天最大时间
    $todayLast   = strtotime(date('Y-m-d 23:59:59'));
    $agoTimeTrue = time() - $targetTime;
    $agoTime     = $todayLast - $targetTime;
    $agoDay      = floor($agoTime / 86400);

    if ($agoTimeTrue < 60) {
        $result = '刚刚';
    } elseif ($agoTimeTrue < 3600) {
        $result = (ceil($agoTimeTrue / 60)) . '分钟前';
    } elseif ($agoTimeTrue < 3600 * 12) {
        $result = (ceil($agoTimeTrue / 3600)) . '小时前';
    } elseif ($agoDay == 0) {
        $result = '今天 ' . date('H:i', $targetTime);
    } elseif ($agoDay == 1) {
        $result = '昨天 ' . date('H:i', $targetTime);
    } elseif ($agoDay == 2) {
        $result = '前天 ' . date('H:i', $targetTime);
    } elseif ($agoDay > 2 && $agoDay < 16) {
        $result = $agoDay . '天前 ' . date('H:i', $targetTime);
    } else {
        $format = date('Y') != date('Y', $targetTime) ? "Y-m-d H:i" : "m-d H:i";
        $result = date($format, $targetTime);
    }
    return $result;
}
// echo "<pre>";
// print_r($list);exit;
// echo "</pre>";

$multi = multi($count, $perpage, $page, $theurl);

$navtitle = lang('space', 'sb_wall', array('who' => $space['username']));
$metakeywords = lang('space', 'sb_wall', array('who' => $space['username']));
$metadescription = lang('space', 'sb_wall', array('who' => $space['username']));
include_once template("diy:home/space_gobuy");

?>